<template>
	<div  class="container">
		<el-page-header @back="goBack" content="通知设置"></el-page-header>
		
		<el-form :label-position="'top'" label-width="auto" :model="form" class="views-form">
			<div class="views-form-con" v-for="(item,index) in form.list" :key="item.id">
				<el-form-item :label="item.notifytype+'：'">
					<el-input type="textarea" v-model="item.content" :autosize='{ minRows: 6, maxRows: 10 }'></el-input>
				</el-form-item>
				<el-form-item v-if="item.notifytypeid > 2">
					<!-- <el-checkbox label="微信提醒" v-model="item.wxremind"></el-checkbox> -->
					<el-checkbox label="短信提醒" v-model="item.smsremind"></el-checkbox>
				</el-form-item>
				<el-form-item class="keySetting col-xs-12">
					<div class="setting keyBox clearfix">
						<el-tag class="wordKey" v-for="(n,i) in item.fields" :key="n.key" @click="keyClick(index, n.key)">{{n.value}}</el-tag>
					</div>
					<span style="color: red;line-height: 30px;"> 注：以上参数仅支持以上编辑框，请匆在其它编辑框中使用</span>
				</el-form-item>
			</div>
			<el-form-item>
			    <el-button type="primary" @click="onSubmit" v-show="utils.checkAdminPermission('系统设置.通知设置.管理')">保存</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		layout: 'admin',
    head() {
      return {
          title:'通知设置-' + this.websetting.name
      }
    },
		data() {
			return {
				form:{
					list:[]
				}
			}
		},
		mounted() {
			this.get()
		},
		methods: {
			goBack() {
				this.$router.go(-1)
			},
			get() {
				this.$axios.get('/notifysetting/list').then((res) => {
					res.forEach((n)=>{
						n.isshow = false;
					})
					this.form.list = res;
				})
			},
			keyClick(index, key) {
				this.form.list[index].content += '{@' + key + '@}';
			},
			onSubmit(){
				this.$axios.post('/notifysetting/save', this.form).then((res) => {
					this.$message.success(res.msg);
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.views-form-con{
		border-bottom: 1px solid #f1f1f1;
		margin-bottom: 15px;
		&:last-child{
			border-bottom: 0;
		}
		.wordKey{
			cursor: pointer;
			margin-right: 5px;
		}
	}
</style>
